package org.example.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.system.model.entity.BizModel;
import org.example.system.model.vo.ModelVo;
import org.example.system.service.BizModelService;
import org.example.system.mapper.BizModelMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author Administrator
* @description 针对表【biz_model(车型表)】的数据库操作Service实现
* @createDate 2024-11-09 19:08:01
*/
@Service
public class BizModelServiceImpl extends ServiceImpl<BizModelMapper, BizModel>
    implements BizModelService{

    @Resource
    private BizModelMapper bizModelMapper;

    public List<ModelVo> getCarTypesWithPrices() {
        List<ModelVo> carTypes = bizModelMapper.getCarTypeWithMinPrice();

        // 为每个对象添加空数组
        carTypes.forEach(model -> model.setChildren(new ArrayList<>()));

        return carTypes;
    }

}




